<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The SolrDocument class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="solrinputdocument.toarray.html">SolrInputDocument::toArray</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="solrdocument.addfield.html">SolrDocument::addField</a></div>
 <div class="up"><a href="book.solr.html">Solr</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.solrdocument" class="reference">

 <h1 class="title">The SolrDocument class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL solr &gt;= 0.9.2)</p>


  <div class="section" id="solrdocument.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    Represents a Solr document retrieved from a query response.
   </p>
  </div>


  <div class="section" id="solrdocument.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">final</span>
      <strong class="classname">SolrDocument</strong>
     </span>
     
     <span class="oointerface">implements 
      <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>
     </span>

     <span class="oointerface">, 
      <span class="interfacename"><strong class="interfacename">Iterator</strong></span>
     </span>

     <span class="oointerface">, 
      <span class="interfacename"><strong class="interfacename">Serializable</strong></span>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-default"><var class="varname">SORT_DEFAULT</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-asc"><var class="varname">SORT_ASC</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-desc"><var class="varname">SORT_DESC</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-name"><var class="varname">SORT_FIELD_NAME</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-value-count"><var class="varname">SORT_FIELD_VALUE_COUNT</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-boost-value"><var class="varname">SORT_FIELD_BOOST_VALUE</var></a></var>
     <span class="initializer"> = 4</span>
    ;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.addfield.html" class="methodname">addField</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.clear.html" class="methodname">clear</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.clone.html" class="methodname">__clone</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="solrdocument.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">SolrDocumentField</span><span class="methodname"><a href="solrdocument.current.html" class="methodname">current</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.deletefield.html" class="methodname">deleteField</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.destruct.html" class="methodname">__destruct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.fieldexists.html" class="methodname">fieldExists</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">SolrDocumentField</span><span class="methodname"><a href="solrdocument.get.html" class="methodname">__get</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">SolrDocumentField</span><span class="methodname"><a href="solrdocument.getfield.html" class="methodname">getField</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="solrdocument.getfieldcount.html" class="methodname">getFieldCount</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span><span class="methodname"><a href="solrdocument.getfieldnames.html" class="methodname">getFieldNames</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">SolrInputDocument</span><span class="methodname"><a href="solrdocument.getinputdocument.html" class="methodname">getInputDocument</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.isset.html" class="methodname">__isset</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="solrdocument.key.html" class="methodname">key</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.merge.html" class="methodname">merge</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.solrdocument.html" class="type SolrDocument">SolrDocument</a></span> <code class="parameter">$sourceDoc</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$overwrite</code><span class="initializer"> = true</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.next.html" class="methodname">next</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.offsetexists.html" class="methodname">offsetExists</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">SolrDocumentField</span><span class="methodname"><a href="solrdocument.offsetget.html" class="methodname">offsetGet</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.offsetset.html" class="methodname">offsetSet</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.offsetunset.html" class="methodname">offsetUnset</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.reset.html" class="methodname">reset</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.rewind.html" class="methodname">rewind</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="solrdocument.serialize.html" class="methodname">serialize</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.set.html" class="methodname">__set</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.sort.html" class="methodname">sort</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$sortOrderBy</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$sortDirection</code><span class="initializer"> = SolrDocument::SORT_ASC</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span><span class="methodname"><a href="solrdocument.toarray.html" class="methodname">toArray</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="solrdocument.unserialize.html" class="methodname">unserialize</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$serialized</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.unset.html" class="methodname">__unset</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="solrdocument.valid.html" class="methodname">valid</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>


  </div>

  

  <div class="section" id="solrdocument.constants">
   <h2 class="title">预定义常量</h2>
   <dl>


    
     <dt id="solrdocument.constants.sort-default"><strong><code>SolrDocument::SORT_DEFAULT</code></strong></dt>

     <dd>

      <p class="para">Default mode for sorting fields within the document.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-asc"><strong><code>SolrDocument::SORT_ASC</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields in ascending order</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-desc"><strong><code>SolrDocument::SORT_DESC</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields in descending order</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-name"><strong><code>SolrDocument::SORT_FIELD_NAME</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by field name.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-value-count"><strong><code>SolrDocument::SORT_FIELD_VALUE_COUNT</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by number of values in each field.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-boost-value"><strong><code>SolrDocument::SORT_FIELD_BOOST_VALUE</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by thier boost values.</p>
     </dd>

    

   </dl>

  </div>



 </div>

 



















































































































































































































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="solrdocument.addfield.html">SolrDocument::addField</a> — Adds a field to the document</li><li><a href="solrdocument.clear.html">SolrDocument::clear</a> — Drops all the fields in the document</li><li><a href="solrdocument.clone.html">SolrDocument::__clone</a> — Creates a copy of a SolrDocument object</li><li><a href="solrdocument.construct.html">SolrDocument::__construct</a> — Constructor</li><li><a href="solrdocument.current.html">SolrDocument::current</a> — Retrieves the current field</li><li><a href="solrdocument.deletefield.html">SolrDocument::deleteField</a> — Removes a field from the document</li><li><a href="solrdocument.destruct.html">SolrDocument::__destruct</a> — Destructor</li><li><a href="solrdocument.fieldexists.html">SolrDocument::fieldExists</a> — Checks if a field exists in the document</li><li><a href="solrdocument.get.html">SolrDocument::__get</a> — Access the field as a property</li><li><a href="solrdocument.getfield.html">SolrDocument::getField</a> — Retrieves a field by name</li><li><a href="solrdocument.getfieldcount.html">SolrDocument::getFieldCount</a> — Returns the number of fields in this document</li><li><a href="solrdocument.getfieldnames.html">SolrDocument::getFieldNames</a> — Returns an array of fields names in the document</li><li><a href="solrdocument.getinputdocument.html">SolrDocument::getInputDocument</a> — Returns a SolrInputDocument equivalent of the object</li><li><a href="solrdocument.isset.html">SolrDocument::__isset</a> — Checks if a field exists</li><li><a href="solrdocument.key.html">SolrDocument::key</a> — Retrieves the current key</li><li><a href="solrdocument.merge.html">SolrDocument::merge</a> — Merges source to the current SolrDocument</li><li><a href="solrdocument.next.html">SolrDocument::next</a> — Moves the internal pointer to the next field</li><li><a href="solrdocument.offsetexists.html">SolrDocument::offsetExists</a> — Checks if a particular field exists</li><li><a href="solrdocument.offsetget.html">SolrDocument::offsetGet</a> — Retrieves a field</li><li><a href="solrdocument.offsetset.html">SolrDocument::offsetSet</a> — Adds a field to the document</li><li><a href="solrdocument.offsetunset.html">SolrDocument::offsetUnset</a> — Removes a field</li><li><a href="solrdocument.reset.html">SolrDocument::reset</a> — This is an alias to SolrDocument::clear()</li><li><a href="solrdocument.rewind.html">SolrDocument::rewind</a> — Resets the internal pointer to the beginning</li><li><a href="solrdocument.serialize.html">SolrDocument::serialize</a> — Used for custom serialization</li><li><a href="solrdocument.set.html">SolrDocument::__set</a> — Adds another field to the document</li><li><a href="solrdocument.sort.html">SolrDocument::sort</a> — Sorts the fields in the document</li><li><a href="solrdocument.toarray.html">SolrDocument::toArray</a> — Returns an array representation of the document</li><li><a href="solrdocument.unserialize.html">SolrDocument::unserialize</a> — Custom serialization of SolrDocument objects</li><li><a href="solrdocument.unset.html">SolrDocument::__unset</a> — Removes a field from the document</li><li><a href="solrdocument.valid.html">SolrDocument::valid</a> — Checks if the current position internally is still valid</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="solrinputdocument.toarray.html">SolrInputDocument::toArray</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="solrdocument.addfield.html">SolrDocument::addField</a></div>
 <div class="up"><a href="book.solr.html">Solr</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
